import java.io.*;
import java.util.ArrayList;

public class NavigateFolder {
	
private File dir;
private String absolutePath="/Users/marcoprocaccini/Dropbox/marcoprocaccini.com/sito/";
	public NavigateFolder(){
		dir = null;
	}
	
	public boolean openDir(String path)
	{
		try{
		dir = new File(path);
		return true;
		}catch(Exception e)
		{
			return false;
		}
	}
	public String getAbsDir(String newPath)
	{
		return absolutePath+newPath;
	}
	
	public ArrayList<String> scanDir(String newPath)
	{
		String path = absolutePath+newPath;
		if(openDir(path))
		{
		ArrayList<String> listaFile = new ArrayList<String>();
        File[] elementi = dir.listFiles();
        if (elementi == null) {
        	return null;
        }
        for (File file : elementi) {
        	String name=file.getName();
            if (name.contains(".jpg"))
            	listaFile.add(name);
        }
        return listaFile;
		}
		else 
			return null;
	}
	

	
	
}
